package com.doit.hbase.client2;

import com.doit.hbase.utils.HbaseUtils;
import org.apache.hadoop.hbase.client.*;

import java.nio.charset.StandardCharsets;
import java.util.Iterator;

/**
 * @DATE 2021/12/16/14:32
 * @Author MDK
 * @Version 2021.2.2
 **/
public class C02_Filter {
    public static void main(String[] args) throws Exception {
        Connection connection = HbaseUtils.getConnection();
        Table table = HbaseUtils.getTable("tb_teacher",connection);
        Scan scan = new Scan();
        //扫描数据范围包括1-3行，不含第三行
        scan.withStartRow("rk001".getBytes());
        scan.withStopRow("rk003".getBytes());

        //扫描数据
        ResultScanner results = table.getScanner(scan);
        Iterator<Result> iterator = results.iterator();
        while (iterator.hasNext()){
            Result result = iterator.next();
            HbaseUtils.show(result);
        }
        table.close();
        connection.close();
    }
}
